#include "MainWindow.hpp"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
    createMenus();
    mainWidget = new MainWidget(this);
    setCentralWidget(mainWidget);
}

MainWindow::~MainWindow(){
}

void MainWindow::createMenuActions(){
    openAction = new QAction(tr("&Open"),this);
    openAction->setShortcuts(QKeySequence::Open);
    openAction->setStatusTip(tr("Open a music file"));
    connect(openAction,SIGNAL(triggered()),this,SLOT(open()));
    quitAction = new QAction(tr("&Quit"),this);
    quitAction->setShortcuts(QKeySequence::Quit);
    connect(quitAction,SIGNAL(triggered()),this,SLOT(quit()));
    aboutAction = new QAction(tr("&About"), this);
    aboutAction->setStatusTip(tr("About the application"));
    connect(aboutAction,SIGNAL(triggered()),this,SLOT(about()));
    preferencesAction = new QAction(tr("&Preferences"),this);
    preferencesAction->setStatusTip(tr("Application preferences"));
    connect(preferencesAction,SIGNAL(triggered()),this,SLOT(preferences()));
}

void MainWindow::createMenus(){
    createMenuActions();
    fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(openAction);
    fileMenu->addAction(quitAction);
    editMenu = menuBar()->addMenu(tr("&Edit"));
    editMenu->addAction(preferencesAction);
    helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(aboutAction);
}

void MainWindow::open(){
    qDebug() << "Open pressed";
}

void MainWindow::quit(){
    qDebug() << "Quit pressed";
}

void MainWindow::preferences(){
    qDebug() << "Preferences pressed";
}

void MainWindow::about(){
    qDebug() << "About pressed";
}
